package com.controller;

import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.ModelAndView;

import com.beans.Adv;
import com.vo.Page;

public class AdvController extends UniversalController {

	public ModelAndView getAdvList(HttpServletRequest request,
			HttpServletResponse response){
		Map result=new HashMap();
		Map param=new HashMap();
		String name=request.getParameter("name");
		if(name!=null&&!"".equals(name))
			param.put("name", name);
		Page page=getUniversalManager().findPageByCriteria(this.getPageNo(request), pageSize, param, Adv.class);
		result.put("o", page);
		return new ModelAndView("admin/advList",result);
	}
	public ModelAndView getAdvEdit(HttpServletRequest request,
			HttpServletResponse response){
		String id=request.getParameter("id");
		Map map=new HashMap();
		if(id==null){
			Adv a=new Adv();
			a.setEnabled("Y");
			map.put("o", a);
			return new ModelAndView("admin/advEdit",map);
		}
		else
		{
			Adv a=(Adv)getUniversalManager().findByID(Adv.class, Integer.parseInt(id));
			map.put("o", a);
			return new ModelAndView("admin/advEdit",map);
		}
	}
}
